﻿<!--
  Copyright © Alexander G. Bykin, Russia 2009-2010
  This source is subject to the Microsoft Public License (Ms-PL).
  Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
  All other rights reserved.
-->

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ctrl="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.RIADataFilter.Control"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:mscore="clr-namespace:System;assembly=mscorlib"
    xmlns:util="clr-namespace:System.Windows.Controls.Data"
    xmlns:dataprim="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
    >

    <mscore:String x:Key="ButtonPlusSource">/System.Windows.Controls.Data.RIADataFilter.Control;component/Images/Plus.png</mscore:String>
    <mscore:String x:Key="ButtonMinusSource">/System.Windows.Controls.Data.RIADataFilter.Control;component/Images/Minus.png</mscore:String>
    <mscore:String x:Key="ButtonClearSource">/System.Windows.Controls.Data.RIADataFilter.Control;component/Images/Clear.png</mscore:String>
    <mscore:String x:Key="ButtonDeleteRowSource">/System.Windows.Controls.Data.RIADataFilter.Control;component/Images/Delete.png</mscore:String>

    <Style TargetType="ctrl:DataFilter">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ctrl:DataFilter">
                    <Grid Background="{TemplateBinding Background}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <StackPanel Grid.Row="0" Orientation="Horizontal">
                            <Button x:Name="btnAddFilter" Margin="0 3 0 3">
                                <Image Source="{StaticResource ButtonPlusSource}"/>
                            </Button>
                            <Button x:Name="btnDeleteFilter" Margin="3 3 0 3">
                                <Image Source="{StaticResource ButtonMinusSource}"/>
                            </Button>
                            <Button x:Name="btnClearFilter" Margin="6 3 0 3">
                                <Image Source="{StaticResource ButtonClearSource}"/>
                            </Button>
                        </StackPanel>

                        <data:DataGrid x:Name="dgFilter" Grid.Row="1"
                                       AutoGenerateColumns="False" CanUserReorderColumns="False">
                            <data:DataGrid.Resources>
                                <util:DynaCommand x:Key="deleteRowCmd"/>
                                <util:DynaObject  x:Key="deleteRowToolTip"/>
                                <util:DynaCommand x:Key="switchFieldsComboOrderByCmd"/>
                                <util:DynaObject  x:Key="switchFieldsComboOrderByToolTip"/>
                                <util:DynaObject  x:Key="fieldsComboOrderByImage"/>
                                <util:DynaString  x:Key="dgcFilterPropertyPathHeader"/>
                            </data:DataGrid.Resources>
                            <data:DataGrid.Columns>
                                <data:DataGridTemplateColumn x:Name="dgcFilterPropertyPath">
                                    <data:DataGridTemplateColumn.HeaderStyle>
                                      <Style TargetType="dataprim:DataGridColumnHeader">
                                        <Setter Property="ContentTemplate">
                                          <Setter.Value>
                                            <DataTemplate>
                                              <StackPanel Orientation="Horizontal">
                                                <Button Command="{Binding Source={StaticResource switchFieldsComboOrderByCmd}, Path=Value}"
                                                        ToolTipService.ToolTip="{Binding Source={StaticResource switchFieldsComboOrderByToolTip}, Path=Value}">
                                                  <Image Source="{Binding Source={StaticResource fieldsComboOrderByImage}, Path=Value}"/>
                                                </Button>
                                                <TextBlock Margin="5,0" VerticalAlignment="Center"
                                                  Text="{Binding Source={StaticResource dgcFilterPropertyPathHeader}, Path=Value}">
                                                </TextBlock>
                                              </StackPanel>
                                            </DataTemplate>
                                          </Setter.Value>
                                        </Setter>
                                      </Style>
                                    </data:DataGridTemplateColumn.HeaderStyle>
                                    <data:DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Path=DisplayName}" VerticalAlignment="Center" Margin="3 0 3 0"/>
                                        </DataTemplate>
                                    </data:DataGridTemplateColumn.CellTemplate>
                                    <data:DataGridTemplateColumn.CellEditingTemplate>
                                        <DataTemplate>
                                            <ComboBox/>
                                        </DataTemplate>
                                    </data:DataGridTemplateColumn.CellEditingTemplate>
                                </data:DataGridTemplateColumn>
                                <data:DataGridTemplateColumn x:Name="dgcFilterOperation">
                                    <data:DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Path=FilterDescriptor.Operator}" VerticalAlignment="Center" Margin="3 0 3 0"/>
                                        </DataTemplate>
                                    </data:DataGridTemplateColumn.CellTemplate>
                                    <data:DataGridTemplateColumn.CellEditingTemplate>
                                        <DataTemplate>
                                            <ComboBox/>
                                        </DataTemplate>
                                    </data:DataGridTemplateColumn.CellEditingTemplate>
                                </data:DataGridTemplateColumn>
                                <data:DataGridTextColumn x:Name="dgcFilterValue" Binding="{Binding Path=FilterDescriptor.Value, Mode=TwoWay}" IsReadOnly="False"/>
                                <data:DataGridTextColumn x:Name="dgcFilterIgnoreValue" Binding="{Binding Path=FilterDescriptor.IgnoredValue, Mode=TwoWay}" IsReadOnly="False"/>
                                <data:DataGridCheckBoxColumn x:Name="dgcFilterIsCaseSensitive" Binding="{Binding Path=FilterDescriptor.IsCaseSensitive, Mode=TwoWay}"/>
                                <data:DataGridTemplateColumn IsReadOnly="True">
                                  <data:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                      <Button Command="{Binding Source={StaticResource deleteRowCmd}, Path=Value}"
                                              CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
                                              ClickMode="Press"
                                              ToolTipService.ToolTip="{Binding Source={StaticResource deleteRowToolTip}, Path=Value}">
                                        <Image Source="{StaticResource ButtonDeleteRowSource}"/>
                                      </Button>
                                    </DataTemplate>
                                  </data:DataGridTemplateColumn.CellTemplate>
                                </data:DataGridTemplateColumn>
                            </data:DataGrid.Columns>
                        </data:DataGrid>

                        <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
                            <Button x:Name="btnApply" FontWeight="Bold" MinWidth="65" MinHeight="25" Margin="5 5 0 5"/>
                            <Button x:Name="btnCancel" FontWeight="Bold" MinWidth="65" MinHeight="25" Margin="5 5 0 5"/>
                        </StackPanel>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ctrl:DataSort">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ctrl:DataSort">
                    <Grid Background="{TemplateBinding Background}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <StackPanel Grid.Row="0" Orientation="Horizontal">
                            <Button x:Name="btnAddSort" Margin="0 3 0 3">
                                <Image Source="{StaticResource ButtonPlusSource}"/>
                            </Button>
                            <Button x:Name="btnDeleteSort" Margin="3 3 0 3">
                                <Image Source="{StaticResource ButtonMinusSource}"/>
                            </Button>
                            <Button x:Name="btnClearSort" Margin="6 3 0 3">
                                <Image Source="{StaticResource ButtonClearSource}"/>
                            </Button>
                        </StackPanel>

                        <data:DataGrid x:Name="dgSort" Grid.Row="1"
                                       AutoGenerateColumns="False" CanUserReorderColumns="False">
                            <data:DataGrid.Resources>
                                <util:DynaCommand x:Key="deleteRowCmd"/>
                                <util:DynaObject  x:Key="deleteRowToolTip"/>
                                <util:DynaCommand x:Key="switchFieldsComboOrderByCmd"/>
                                <util:DynaObject  x:Key="switchFieldsComboOrderByToolTip"/>
                                <util:DynaObject  x:Key="fieldsComboOrderByImage"/>
                                <util:DynaString  x:Key="dgcSortPropertyPathHeader"/>
                            </data:DataGrid.Resources>
                            <data:DataGrid.Columns>
                                <data:DataGridTemplateColumn x:Name="dgcSortPropertyPath">
                                    <data:DataGridTemplateColumn.HeaderStyle>
                                      <Style TargetType="dataprim:DataGridColumnHeader">
                                        <Setter Property="ContentTemplate">
                                          <Setter.Value>
                                            <DataTemplate>
                                              <StackPanel Orientation="Horizontal">
                                                <Button Command="{Binding Source={StaticResource switchFieldsComboOrderByCmd}, Path=Value}"
                                                        ToolTipService.ToolTip="{Binding Source={StaticResource switchFieldsComboOrderByToolTip}, Path=Value}">
                                                  <Image Source="{Binding Source={StaticResource fieldsComboOrderByImage}, Path=Value}"/>
                                                </Button>
                                                <TextBlock Margin="5,0" VerticalAlignment="Center"
                                                  Text="{Binding Source={StaticResource dgcSortPropertyPathHeader}, Path=Value}">
                                                </TextBlock>
                                              </StackPanel>
                                            </DataTemplate>
                                          </Setter.Value>
                                        </Setter>
                                      </Style>
                                    </data:DataGridTemplateColumn.HeaderStyle>
                                    <data:DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Path=DisplayName}" VerticalAlignment="Center" Margin="3 0 3 0"/>
                                        </DataTemplate>
                                    </data:DataGridTemplateColumn.CellTemplate>
                                    <data:DataGridTemplateColumn.CellEditingTemplate>
                                        <DataTemplate>
                                            <ComboBox/>
                                        </DataTemplate>
                                    </data:DataGridTemplateColumn.CellEditingTemplate>
                                </data:DataGridTemplateColumn>
                                <data:DataGridTemplateColumn x:Name="dgcSortDirection">
                                    <data:DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Path=SortDescriptor.Direction}" VerticalAlignment="Center" Margin="3 0 3 0"/>
                                        </DataTemplate>
                                    </data:DataGridTemplateColumn.CellTemplate>
                                    <data:DataGridTemplateColumn.CellEditingTemplate>
                                        <DataTemplate>
                                            <ComboBox/>
                                        </DataTemplate>
                                    </data:DataGridTemplateColumn.CellEditingTemplate>
                                </data:DataGridTemplateColumn>
                                <data:DataGridTemplateColumn IsReadOnly="True">
                                  <data:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                      <Button Command="{Binding Source={StaticResource deleteRowCmd}, Path=Value}"
                                              CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
                                              ClickMode="Press"
                                              ToolTipService.ToolTip="{Binding Source={StaticResource deleteRowToolTip}, Path=Value}">
                                        <Image Source="{StaticResource ButtonDeleteRowSource}"/>
                                      </Button>
                                    </DataTemplate>
                                  </data:DataGridTemplateColumn.CellTemplate>
                                </data:DataGridTemplateColumn>
                            </data:DataGrid.Columns>
                        </data:DataGrid>

                        <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
                            <Button x:Name="btnApply" FontWeight="Bold" MinWidth="65" MinHeight="25" Margin="5 5 0 5"/>
                            <Button x:Name="btnCancel" FontWeight="Bold" MinWidth="65" MinHeight="25" Margin="5 5 0 5"/>
                        </StackPanel>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ctrl:DataGroup">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ctrl:DataGroup">
                    <Grid Background="{TemplateBinding Background}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <StackPanel Grid.Row="0" Orientation="Horizontal">
                            <Button x:Name="btnAddGroup" Margin="0 3 0 3">
                                <Image Source="{StaticResource ButtonPlusSource}"/>
                            </Button>
                            <Button x:Name="btnDeleteGroup" Margin="3 3 0 3">
                                <Image Source="{StaticResource ButtonMinusSource}"/>
                            </Button>
                            <Button x:Name="btnClearGroup" Margin="6 3 0 3">
                                <Image Source="{StaticResource ButtonClearSource}"/>
                            </Button>
                        </StackPanel>

                        <data:DataGrid x:Name="dgGroup" Grid.Row="1"
                                       AutoGenerateColumns="False" CanUserReorderColumns="False">
                            <data:DataGrid.Resources>
                                <util:DynaCommand x:Key="deleteRowCmd"/>
                                <util:DynaObject  x:Key="deleteRowToolTip"/>
                                <util:DynaCommand x:Key="switchFieldsComboOrderByCmd"/>
                                <util:DynaObject  x:Key="switchFieldsComboOrderByToolTip"/>
                                <util:DynaObject  x:Key="fieldsComboOrderByImage"/>
                                <util:DynaString  x:Key="dgcGroupPropertyPathHeader"/>
                            </data:DataGrid.Resources>
                            <data:DataGrid.Columns>
                                <data:DataGridTemplateColumn x:Name="dgcGroupPropertyPath">
                                    <data:DataGridTemplateColumn.HeaderStyle>
                                      <Style TargetType="dataprim:DataGridColumnHeader">
                                        <Setter Property="ContentTemplate">
                                          <Setter.Value>
                                            <DataTemplate>
                                              <StackPanel Orientation="Horizontal">
                                                <Button Command="{Binding Source={StaticResource switchFieldsComboOrderByCmd}, Path=Value}"
                                                        ToolTipService.ToolTip="{Binding Source={StaticResource switchFieldsComboOrderByToolTip}, Path=Value}">
                                                  <Image Source="{Binding Source={StaticResource fieldsComboOrderByImage}, Path=Value}"/>
                                                </Button>
                                                <TextBlock Margin="5,0" VerticalAlignment="Center"
                                                  Text="{Binding Source={StaticResource dgcGroupPropertyPathHeader}, Path=Value}">
                                                </TextBlock>
                                              </StackPanel>
                                            </DataTemplate>
                                          </Setter.Value>
                                        </Setter>
                                      </Style>
                                    </data:DataGridTemplateColumn.HeaderStyle>
                                    <data:DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Path=DisplayName}" VerticalAlignment="Center" Margin="3 0 3 0"/>
                                        </DataTemplate>
                                    </data:DataGridTemplateColumn.CellTemplate>
                                    <data:DataGridTemplateColumn.CellEditingTemplate>
                                        <DataTemplate>
                                            <ComboBox/>
                                        </DataTemplate>
                                    </data:DataGridTemplateColumn.CellEditingTemplate>
                                </data:DataGridTemplateColumn>
                                <data:DataGridTemplateColumn IsReadOnly="True">
                                  <data:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                      <Button Command="{Binding Source={StaticResource deleteRowCmd}, Path=Value}"
                                              CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
                                              ClickMode="Press"
                                              ToolTipService.ToolTip="{Binding Source={StaticResource deleteRowToolTip}, Path=Value}">
                                        <Image Source="{StaticResource ButtonDeleteRowSource}"/>
                                      </Button>
                                    </DataTemplate>
                                  </data:DataGridTemplateColumn.CellTemplate>
                                </data:DataGridTemplateColumn>
                            </data:DataGrid.Columns>
                        </data:DataGrid>

                        <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
                            <Button x:Name="btnApply" FontWeight="Bold" MinWidth="65" MinHeight="25" Margin="5 5 0 5"/>
                            <Button x:Name="btnCancel" FontWeight="Bold" MinWidth="65" MinHeight="25" Margin="5 5 0 5"/>
                        </StackPanel>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
